﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KMFrame.Core
{
    public class PageResult
    {
        private int _PageIndex = 1;
        private int _PageSize = 10;
        private int _PageCount = -1;
        private int _TotalCount = -1;

        public int PageIndex { get { return _PageIndex; } set { _PageIndex = value; } }
        public int PageSize
        {
            get { return _PageSize; }
            set
            {
                _PageSize = value;
                if (_TotalCount > 0 && _PageSize > 0)
                {
                    _PageCount = _TotalCount / _PageSize;
                    if (_TotalCount % _PageSize > 0)
                        _PageCount++;
                }
            }
        }
        public int PageCount { get { return _PageCount; } set { _PageCount = value; } }
        public int TotalCount
        {
            get { return _TotalCount; }
            set
            {
                _TotalCount = value;
                if (_TotalCount > 0 && _PageSize > 0)
                {
                    _PageCount = _TotalCount / _PageSize;
                    if (_TotalCount % _PageSize > 0)
                        _PageCount++;
                }
            }
        }
        public IEnumerable<object> ResultList { get; set; }
    }

    public class PageParam
    {
        private int _PageIndex = 1;
        private int _PageSize = 10;
        private int _PageCount = -1;
        private int _TotalCount = -1;

        public int PageIndex { get { return _PageIndex; } set { _PageIndex = value; } }
        public int PageSize { get { return _PageSize; } set { _PageSize = value; } }
        public int PageCount { get { return _PageCount; } set { _PageCount = value; } }
        public int TotalCount { get { return _TotalCount; } set { _TotalCount = value; } }
    }
}
